(function () {
    "use strict";

    angular.module('core').factory('planoAbastecimentoService', factory);
    factory.$inject = ['$http', '$q'];

    function factory($http, $q) {

        var _get = function (id) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/get', id)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };
        var _getAll = function (args) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/getall', args)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _count = function (args) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/count', args)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _prepareNew = function () {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/prepareNew')
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };
        var _prepare = function (item) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/prepare', item)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };
        var _prepareNewVariante = function (item) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/prepareNewVariante', item)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };
   
        var _prepareNewPrecoPlanoAbastecimento = function (item) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/prepareNewPrecoPlanoAbastecimento', item)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        var _save = function (item) {
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/save', item)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };
        var _delete = function (id) {
            var args = { id: id };
            var deferred = $q.defer();
            $http.post('/PlanoAbastecimento/delete', args)
                .success(function (data) { deferred.resolve(data); })
                .error(function (data, status, headers, config) { deferred.reject(data); });
            return deferred.promise;
        };

        return {
            get: _get,
            getAll: _getAll,
            count: _count,
            prepareNew: _prepareNew,
            prepare: _prepare,
            prepareNewVariante: _prepareNewVariante,
            prepareNewPrecoPlanoAbastecimento: _prepareNewPrecoPlanoAbastecimento,
            save: _save,
            delete: _delete
        };
    }

})();


